package com.his.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.his.pojo.HisDrug;
import com.his.pojo.HisResidentdoctor;
import com.his.service.hy.MedicalcardService;
import com.his.service.hy.ResidentdoctorService;
import com.his.vo.hy.Brcf;
import com.his.vo.hy.CaoZuo;
import com.his.vo.hy.HisPatientVo;
import com.his.vo.hy.HospitalprescriptionVo;
import com.his.vo.hy.LeavehospitalVo;
import com.his.vo.hy.MedicalcardRegistionVo;

@Controller

public class HisController {
	@Autowired
	private MedicalcardService mcardService;
	@Autowired
	private ResidentdoctorService residentdoctorService;
	
	
	
	//显示所有住院通知单
	@RequestMapping("/zytzall")
	public @ResponseBody Map<String, Object> zytzall(int page,int rows){
	return mcardService.selectHisHospitalizationAll(page, rows);	
	}
	
	//显示住院通知
	@RequestMapping("/zytz")
	public String zytz(){
		return "zytz";
	}
	
	//根据医疗卡查询
	@RequestMapping("/cxylkno")
	public @ResponseBody Map<String, Object> cxylkno(long ylkNo){
	return mcardService.selceylknot(ylkNo);
	}
	
	//保存病人登记信息
	@RequestMapping("/bcjbxx")
	public @ResponseBody CaoZuo  bcjbxx(MedicalcardRegistionVo br){
		mcardService.savePatient(br);
		return new CaoZuo(true,"登记成功");
	}
	
	//查询所有病人
	@RequestMapping("/patientAll")
	public @ResponseBody Map<String, Object> patientAll(int page,int rows){
	return mcardService.selectPatientAll(page, rows);	
	}
	
	//显示病人信息
	@RequestMapping("/brxx")
	public @ResponseBody HisPatientVo brxx(long brNo){
		HisPatientVo  m = mcardService.selectbrxx(brNo);
			if(m==null){
				m=null;
			}
			return m;
		
	}
	
	//入住选择
	@RequestMapping("/torz")
	public String to_rz(){
		return "rz";
	}
	
	//查询可是床位
	@RequestMapping("/cw")
	public @ResponseBody  Map<String, Object> cw(long bqNo){
		return mcardService.selectkscw(bqNo);
		
	}
	
	//保存选择的床位
	@RequestMapping("/xzcw")
	public @ResponseBody CaoZuo  xzcw(long brNo,long cwNo){
		
		return mcardService.savecw(brNo, cwNo);
	}
	
	//保存选择的医生
	@RequestMapping("/xzys")
	public @ResponseBody CaoZuo  xzys(long brNo,long ysNo){
		System.out.println(ysNo);
		return mcardService.saveys(brNo, ysNo);
		
	}
	
	//查询科室医生
	@RequestMapping("/ys")
	public @ResponseBody  Map<String, Object> ys(long bqNo){
		return mcardService.selectksys(bqNo);
		
	}
	
	//护士工作界面
	@RequestMapping("/tohisnurse")
	public String tohhisnurse(){
		return "HisNurse";
	}
	
	@RequestMapping("/tozhuyuan")
	public String tozhuyuan(){
		return "HisZhuYuan";
	}
	
	//
	@RequestMapping("/tomm")
	public @ResponseBody MedicalcardRegistionVo to_mm(long ylkNo){
		MedicalcardRegistionVo  m = mcardService.selectMedicalCard(ylkNo);
			if(m==null){
				m=null;
			}
			return m;
	}
	
	//显示病床管理
	@RequestMapping("/tobcgl")
	public String tobcgl(){
		return "bcgl";
	}

	@RequestMapping("/his")
	public String his(){
		return "his";
	}
	
	//根据病人姓名查询
	@RequestMapping("/selectBrname")
	public @ResponseBody Map<String , Object> selectBrname(String ss){
		return mcardService.selectBrname(ss);
	}
	//根据医疗卡查询
	@RequestMapping("/selectYlkno")
	public @ResponseBody Map<String , Object> selectYlkno(long ss){
		return mcardService.selectYlkno(ss);
	}
	
	@RequestMapping("/toys")
	public @ResponseBody List<HisResidentdoctor> to_ys(){
			List<HisResidentdoctor> r = residentdoctorService.selectResidentDocotorall();
			return r;
		
	}
	
	@RequestMapping("/selectcwxx")
	public @ResponseBody HisPatientVo selectcwxx(long cw){
		HisPatientVo  m = mcardService.selectcw(cw);
			if(m==null){
				m=null;
			}
			return m;
		
	}

	
	//显示医生工作界面
	@RequestMapping("/tohisdoctor")
	public String tohisdoctor(){
		return "Hisdoctor";
	}

	@RequestMapping("/selectysbr")
	public @ResponseBody Map<String , Object> selectysbr(long zyysno){
		return mcardService.selectysbr(zyysno);
	}
	
	//
	@RequestMapping("/zyysbr")
	public String zyysbr(){
		return "zyysbr";
	}
	
	//开出院通知单
	@RequestMapping("/kcytz")
	public String kcytz(){
		return "kcytz";
	}

	//添加处方
	@RequestMapping("/insertzycf")
	public @ResponseBody CaoZuo insertzycf(HospitalprescriptionVo hisp){
		
		mcardService.insertzycf(hisp);
		
		return new CaoZuo(true,"添加成功"); 
	}
	
	//查询药品
	@RequestMapping("/selectdrug")
	public @ResponseBody List<HisDrug> selectdrug(){
		
		return mcardService.selectDrug();
	}
	
	//查询病人处方
	@RequestMapping("/selectyp")
	public @ResponseBody Brcf selectyp(long brNo){
		
		return mcardService.selectyp(brNo);
	}
	
	//查询所有通知单
	@RequestMapping("/selectcytz")
	public @ResponseBody Map<String, Object>  selectcytz(int page,int rows){	
		return mcardService.selectLeavehospital(page, rows);
	}
	
	//保存出院通知单
	@RequestMapping("/savecytzd")
	public @ResponseBody CaoZuo savecytzd(LeavehospitalVo cytz){	
		return mcardService.cytz(cytz);
	}
	
	//显示住出院通知
	@RequestMapping("/cytz")
	public String cytz(){
		return "cytz";
	}
	
	//显示开出院通知
	@RequestMapping("/cytzd")
	public String cytzd(){
		return "cytzd";
	}
	
	//查询病人
	@RequestMapping("/selectbr")
	public @ResponseBody HisPatientVo selectbr(long ylkNo){
		return mcardService.selectbr(ylkNo);
	}
	
	//办理出院
	@RequestMapping("/cysx")
	public @ResponseBody CaoZuo cysx(long brno,long cyno){
		return mcardService.cysx(brno, cyno);
	}
	
	//更改病人情况
	@RequestMapping("/ggbrqk")
	public @ResponseBody CaoZuo ggbrqk(long brNo,String brSituation){
		return mcardService.updaebrqk(brNo, brSituation);
	}
	
	//更换床位
	@RequestMapping("/ghcw")
	public @ResponseBody CaoZuo ghcw(long brno,long cwno){
		return mcardService.ghcw(brno, cwno);
	}
	
	//显示开出院通知
	@RequestMapping("/zyjf")
	public String zyjf(){
		return "zyjf";
	}
	
	//住院缴费
	@RequestMapping("/brzyjf")
	public @ResponseBody CaoZuo brzyjf(long brno,double jfje){
		return mcardService.zyjf(brno, jfje);
	}
	
	//查询所有住院病人
	@RequestMapping("/selectzybrall")
	public @ResponseBody Map<String , Object> selectzybrall(){
		return mcardService.selectzybrall();
	}
	
	//住院退费
	@RequestMapping("/zytf")
	public  @ResponseBody CaoZuo zytf(long brno,double ye){
		return mcardService.zytf(brno, ye);
	}

}
